package com.ibuonline.b2b.entity;

import java.io.Serializable;

public class CompanyCertificate implements Serializable {

	private static final long serialVersionUID = -3086693673407174942L;

	//fields
	private java.lang.Integer id;
	private java.lang.Integer companyId;
	private java.lang.String name;
	private java.lang.String pic;
	private java.lang.String type;
	private java.lang.String authority;
	private java.sql.Timestamp effectDate;
	private java.sql.Timestamp expireDate;
	private java.lang.String status;
	private java.sql.Timestamp lastupdate;
	
	private String companyName;

	//default constructor
	public CompanyCertificate() {
	}

	//getter
	public java.lang.Integer getId() {
		return id;
	}
	public java.lang.Integer getCompanyId() {
		return companyId;
	}
	public java.lang.String getName() {
		return name;
	}
	public java.lang.String getPic() {
		return pic;
	}
	public java.lang.String getType() {
		return type;
	}
	public java.lang.String getAuthority() {
		return authority;
	}
	public java.sql.Timestamp getEffectDate() {
		return effectDate;
	}
	public java.sql.Timestamp getExpireDate() {
		return expireDate;
	}
	public java.lang.String getStatus() {
		return status;
	}
	public java.sql.Timestamp getLastupdate() {
		return lastupdate;
	}

	//setter
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public void setCompanyId(java.lang.Integer companyId) {
		this.companyId = companyId;
	}
	public void setName(java.lang.String name) {
		this.name = name;
	}
	public void setPic(java.lang.String pic) {
		this.pic = pic;
	}
	public void setType(java.lang.String type) {
		this.type = type;
	}
	public void setAuthority(java.lang.String authority) {
		this.authority = authority;
	}
	public void setEffectDate(java.sql.Timestamp effectDate) {
		this.effectDate = effectDate;
	}
	public void setExpireDate(java.sql.Timestamp expireDate) {
		this.expireDate = expireDate;
	}
	public void setStatus(java.lang.String status) {
		this.status = status;
	}
	public void setLastupdate(java.sql.Timestamp lastupdate) {
		this.lastupdate = lastupdate;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof CompanyCertificate))
			return false;

		final CompanyCertificate certificate = (CompanyCertificate)other;
		if (!this.id.equals(certificate.getId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(id).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("CompanyCertificate[")
			.append("id=").append(id).append(", ")
			.append("companyName=").append(companyName).append(",")
			.append("companyId=").append(companyId).append(", ")
			.append("name=").append(name).append(", ")
			.append("pic=").append(pic).append(", ")
			.append("type=").append(type).append(", ")
			.append("authority=").append(authority).append(", ")
			.append("effectDate=").append(effectDate).append(", ")
			.append("expireDate=").append(expireDate).append(", ")
			.append("status=").append(status).append(", ")
			.append("lastupdate=").append(lastupdate).append("]").toString();
	}

	///############################
	public String getWaterPic() {
		if (pic == null) return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(pic, com.ibuonline.b2b.common.Constants.PIC_SIZE_WATER);
	}
	
	public String getLargePic() {
		if (pic == null) return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(pic, com.ibuonline.b2b.common.Constants.PIC_SIZE_LARGE);
	}
	
	public String getMiddlePic() {
		if (pic == null) return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(pic, com.ibuonline.b2b.common.Constants.PIC_SIZE_MIDDLE);
	}
	
	public String getSmallPic() {
		if (pic == null) return null;
		return com.ibuonline.b2b.common.ResourceUtil.getResPath(pic, com.ibuonline.b2b.common.Constants.PIC_SIZE_SMALL);
	}
	
	public String getCerName() {
		if (name != null && name.length() > 15) {
			return name.substring(0, 15) + "...";
		} else {
			return name;
		}
	}
	public String getAuthorityName() {
		if (authority != null && authority.length() > 10) {
			return authority.substring(0, 10) + "...";
		} else {
			return authority;
		}
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	
}
